const merge= require('webpack-merge')
const baseConfig = require('./webpack.common.js')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const OptimizeCssAssetsWebpackPlugin = require('optimize-css-assets-webpack-plugin')
const TerSerWebpackPlugin = require('terser-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = merge(baseConfig,{
  mode:"production",
  devtool:"none",
  optimization:{
    minimizer:[
      new TerSerWebpackPlugin(),
      new OptimizeCssAssetsWebpackPlugin()
    ]
  },
  module:{
    rules:[
      {
        test: /\.(css|less)?$/,
        use:[MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
      },
    ]
  },
  plugins:[
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin(['public']),
    new MiniCssExtractPlugin()
  ]
})

